package com.neutech.service.impl;

import com.neutech.dao.BusinessDAO;
import com.neutech.dao.impl.BusinessDAOImpl;
import com.neutech.entity.Business;
import com.neutech.service.BusinessService;
import com.neutech.vo.ResultVO;

import java.util.List;

public class BusinessServiceImpl implements BusinessService {
    private BusinessDAO businessDAO = new BusinessDAOImpl();

    @Override
    public ResultVO listBusiness() {
        return ResultVO.success(businessDAO.listBusiness());
    }

    @Override
    public ResultVO getById(Integer id) {
        Business business = businessDAO.getById(id);
        if (business == null) {
            return ResultVO.error(2001,"数据不存在");
        }
        return ResultVO.success(business);
    }

    @Override
    public ResultVO search(String searchName) {
        Business business = businessDAO.searchByName(searchName);
        if (business == null) {
            return ResultVO.error(2001,"商家不存在");
        }
        return ResultVO.success(business);
    }
}
